{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "+<img src=\".\\\\+diyLogo.png\" alt=\"some_text\">\n",
    "<h1> 第一讲 基本数据结构</h1>\n",
    "<a id=backup></a>\n",
    "<H2>目录</H2>  \n",
    "\n",
    "[1.1 数字常量](#Literals)   \n",
    "[1.2 标准数据类型](#data_type)   \n",
    "[1.3 数字类型的操作](#num_opr)   \n",
    "[1.4 字符串](#char_opr)  \n",
    "[1.5 Latex数学公式编辑](#Latex_form) \n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<table><tr><th>int</th><th>long</th><th>float</th><th>complex</th></tr>\n",
    "<tr><td>10</td><td>51924361L</td><td>0.0</td><td>3.14j</td></tr>\n",
    "<tr><td>100</td><td>-0x19323L</td><td>15.20</td><td>45.j</td></tr>\n",
    "<tr><td>-786</td><td>0122L</td><td>-21.9</td><td>9.322e-36j</td></tr>\n",
    "<tr><td>080</td><td>0xDEFABCECBDAECBFBAEl</td><td>32.3e+18</td><td>.876j</td></tr>\n",
    "<tr><td>-0490</td><td>535633629843L</td><td>-90.</td><td>-.6545+0J</td></tr>\n",
    "<tr><td>-0x260</td><td>-052318172735L</td><td>-32.54e100</td><td>3e+26J</td></tr>\n",
    "<tr><td>0x69</td><td>-4721885298529L</td><td>70.2E-12</td><td>4.53e-7j</td></tr>\n",
    "</table>"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<a id=\"data_struc\"></a>\n",
    "### 1.1 数字常量\n",
    "\n",
    "Python3 支持 **int、float、bool、complex**（复数）。\n",
    "\n",
    "在Python 3里，只有一种整数类型 **int**，表示为长整型，没有 python2 中的 **Long**。\n",
    "\n",
    "像大多数语言一样，数值类型的赋值和计算都是很直观的。\n",
    "\n",
    "内置的 type() 函数可以用来查询变量所指的对象类型。\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(2-5j)\n"
     ]
    }
   ],
   "source": [
    "z=2+5j\n",
    "type(z) \n",
    "print(z.conjugate())"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "与数学中的整数概念一致，没有取值范围限制\n",
    "pow(x, y)函数：\n",
    "计算 $$x^{y}$$\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "4149515568880992958512407863691161151012446232242436899995657329690652811412908146399707048947103794288197886611300789182395151075411775307886874834113963687061181803401509523685376"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pow(2,600)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "sys.float_info(max=1.7976931348623157e+308, max_exp=1024, max_10_exp=308, min=2.2250738585072014e-308, min_exp=-1021, min_10_exp=-307, dig=15, mant_dig=53, epsilon=2.220446049250313e-16, radix=2, rounds=1)\n",
      "sys.int_info(bits_per_digit=30, sizeof_digit=4)\n"
     ]
    }
   ],
   "source": [
    "import sys\n",
    "print(sys.float_info)\n",
    "print(sys.int_info)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<a id=\"data_type\"></a>\n",
    "## 1.2 标准数据类型\n",
    "<h3 style=\"color:green\"> Python3 中有六个标准的数据类型：</h3>\n",
    "  \n",
    "<table border=\"1\">\n",
    "    <tr>\n",
    "        <td> Number</td>\n",
    "        <td>数字</td>\n",
    "    </tr>\n",
    "    <tr>\n",
    "        <td>String</td>\n",
    "        <td>字符串</td>\n",
    "    </tr>\n",
    "    <tr>\n",
    "        <td>List</td>\n",
    "        <td>列表</td>\n",
    "    </tr>    \n",
    "    <tr>\n",
    "        <td>Tuple</td>\n",
    "        <td>元组</td>\n",
    "    </tr>    \n",
    "    <tr>\n",
    "        <td>Set</td>\n",
    "        <td>集合</td>\n",
    "    </tr>\n",
    "    <tr>\n",
    "        <td>Dictionary</td>\n",
    "        <td>字典</td>\n",
    "    </tr>\n",
    "</table>\n",
    "<h3 style=\"color:green\">Python3 的六个标准数据类型中：</h3>\n",
    "\n",
    "不可变数据（3 个）：Number（数字）、String（字符串）、Tuple（元组）；  \n",
    "可变数据（3 个）：List（列表）、Dictionary（字典）、Set（集合）。  \n",
    "\n",
    "[目录](#backup) "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "100\n",
      "1000.0\n",
      "ru'n'oob\n",
      "{'apple', 'banana', 'pear', 'orange'}\n"
     ]
    }
   ],
   "source": [
    "counter = 100       # 整型变量\n",
    "miles = 1000.0      # 浮点型变量\n",
    "name = \"ru'n'oob\"         # 字符串\n",
    "name2='xauat\"edu\"'\n",
    "name3='''a \n",
    "b\n",
    " c '''\n",
    "list1  = [1, 2, 3, 4, 5] # 列表\n",
    "tup1 = (1, 2, 3, 4, 5)  # 元 组\n",
    "dict = {'name': '张三', 'age': 15, 'Mail': 'zhs@163.com'} # 字典\n",
    "basket = {'apple', 'orange', 'apple', 'pear', 'orange', 'banana'} # 集合\n",
    "print(counter)\n",
    "print(miles)\n",
    "print(name)\n",
    "print(basket)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<a id=\"num_opr\"></a>\n",
    "## 1.3 数字类型的操作\n",
    "数值计算+ - * /\n",
    "\n",
    "[目录](#backup) "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "a+b= 2\n",
      "a*b= 1\n",
      "a/b= 2.6666666666666665\n",
      "a//b= 2\n",
      "a%b = 2\n",
      "a**b= 512\n"
     ]
    }
   ],
   "source": [
    "a = b = 1\n",
    "c=a+b\n",
    "print(\"a+b=\", c)\n",
    "c=a*b\n",
    "print(\"a*b=\", c)\n",
    "a=8\n",
    "b=3\n",
    "c=a/b\n",
    "print(\"a/b=\", c)\n",
    "c=a//b\n",
    "print(\"a//b=\", c)\n",
    "c = a%b\n",
    "print(\"a%b =\", c)\n",
    "c = a ** b\n",
    "print(\"a**b=\", c)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<a id=\"char_opr\"></a>\n",
    "## 1.4 字符串变量操作\n",
    "字符串是 Python 中最常用的数据类型。我们可以使用引号( ' 、 \" 或 ''')来创建字符串。\n",
    "\n",
    "创建字符串很简单，只要为变量分配一个值即可。例如：\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "var1 = 'Hello World!'\n",
    "var2 = \"Runoob\"\n",
    "var3='''Hello World '''"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Python 访问字符串中的值\n",
    "Python 不支持单字符类型，单字符在 Python 中也是作为一个字符串使用。\n",
    "\n",
    "Python 访问子字符串，可以使用方括号 [] 来截取字符串，字符串的截取的语法格式如下：\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "ello\n"
     ]
    }
   ],
   "source": [
    "print(var1[1:5])\n",
    "        "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "\n",
    "[目录](#backup) "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<a id=\"Latex_form\"></a>\n",
    "## 1.5 Latex数学公式编辑\n",
    "在jupyter notebook使用latex编辑数学公式\n",
    "使用下划线_表示下标，使用^表示上标\n",
    "\n",
    "$${\\ x}^{5}   \\ x_i\n",
    "\n",
    "\\varPsi =\\int_{a}^{b}  \\,d\\alpha \n",
    "$$\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "$$\n",
    "x_{(22)}^{(n)}\\qquad   \n",
    "\\frac{1}{1+\\frac{1}{2}}\\qquad  \n",
    "\\sqrt{1+\\sqrt[^p]{1+a^2}}\\qquad  \n",
    "\\int_1^\\infty\\qquad  \n",
    "\\sum_{k=1}^n\\frac{1}{k}\\qquad  \n",
    "\\int_a^b f(x)dx\\qquad  \n",
    "\\frac{\\partial E_w}{\\partial w}\\qquad  \n",
    "\\lim_{1\\to\\infty}\\qquad  \n",
    "\\lt \\gt \\le \\ge \\neq \\not\\lt \\neq\\qquad  \n",
    "\\times \\div \\pm \\mp x \\cdot y\\qquad  \n",
    "\\cup \\cap \\setminus \\subset \\subseteq \\subsetneq \\supset \\in \\notin \\emptyset   \\varnothing\\qquad  \n",
    "\\to \\rightarrow \\leftarrow \\Rightarrow \\Leftarrow \\mapsto\\qquad  \n",
    "\\land \\lor \\lnot \\forall \\exists \\top \\bot \\vdash \\vDash\\qquad  \n",
    "\\star \\ast \\oplus \\circ \\bullet\\qquad  \n",
    "\\approx \\sim \\cong \\equiv \\prec\\qquad  \n",
    "\\infty \\aleph \\nabla \\partial\\qquad  \n",
    "\\epsilon \\varepsilon\\qquad  \n",
    "\\phi \\varphi\\qquad  \n",
    "\\left \\lbrace \\sum_{i=0}^n i^2 = \\frac{(n^2+n)(2n+1)}{6} \\right\\rbrace \\qquad  \n",
    "\\left( \\sum_{k=\\frac{1}{2}}^{N^2}\\frac{1}{k} \\right)\\qquad  \n",
    "\\left. \\frac{\\partial f(x, y)}{\\partial x}\\right|_{x=0}\\qquad  \n",
    "\\left\\lbrace\\begin{aligned}a\\\\a\\\\a\\\\\\end{aligned}\\right\\rbrace \\qquad  \n",
    "\\left\\lbrace\\begin{aligned}  \n",
    "a_1x+b_1y+c_1z &=d_1+e_1 \\\\\\ \n",
    "a_2x+b_2y &=d_2 \\\\\\ \n",
    "a_3x+b_3y+c_3z &=d_3\n",
    "\\end{aligned}\\right\\rbrace \\qquad  \n",
    "$$\n"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3.10.4 ('python310')",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.4"
  },
  "orig_nbformat": 4,
  "vscode": {
   "interpreter": {
    "hash": "a888cd810c90be07c3c921372a6d7ff433f5a38d5779dfb2a871d99db75673fb"
   }
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
